import math
import sys
import os

# 第六章
x = 10
y = 20


# 列表

list1 = ['Google', 'Runoob', 1997, 2000]
list2 = [1, 2, 3, 4, 5 ]
list3 = ["a", "b", "c", "d"]
list4 = ['red', 'green', 'blue', 'yellow', 'white', 'black']
# 索引为0开始，列表的数据项不需要具有相同的类型
# 列表拼接
squares = [1, 4, 9, 16, 25]
squares += [36, 49, 64, 81, 100]
# print(squares)
# [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]


# 元组
tup1 = ('Google', 'Runoob', 1997, 2000)
tup2 = (1, 2, 3, 4, 5 )
tup3 = "a", "b", "c", "d"   #  不需要括号也可以
# print(type(tup3))

# 元组中的元素不可修改

# 字典
dict1 = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3258'}
dict2 = {'name': ['John', 'Emily', 'Michael'], 'age': [25, 30, 36], 'city': ['Los Angeles', 'Chicago', 'New York']}
# 访问字典中的元素
# print(dict2['name'])#字典数据和列表的组合，key为字符串，value为列表

# 集合
set1 = {1, 2, 3, 4}            # 直接使用大括号创建集合
set2 = set([4, 5, 6, 7])      # 使用 set() 函数从列表创建集合

# 基本语法  if while
# 推导式
# 文件和输入输出 
# with open('test.txt', 'w+') as fp:

# fp = open('test.txt', 'r+')
# fp.write('Hello, world!\n')

# fp.close()


# 异常处理
try:
    filename =input("Enter file name: ")
    file = open(filename, 'r')
    for each_line in file:
        print(each_line)
    file.close()
except IOError:
    print("File not found")


# 第十六章 网络编程（套接字编程）

